#!/bin/bash
hdiutil detach /Volumes/Bootstick 2>/dev/null
hdiutil detach /Volumes/r_image 2>/dev/null
hdiutil detach /Volumes/OS\ X\ Base\ System*/ 2>/dev/null
hdiutil detach /Volumes/OS\ X\ Base\ System/ 2>/dev/null
hdiutil detach /Volumes/OS\ X\ Base\ System\ 1/ 2>/dev/null




clear
if test -e /Volumes/OS\ X\ Base\ System/
then
        echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo          found Volume OS X Base System
	echo
	echo    Remove it, or rename it. And start this tool again
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
exit
else
        echo +
fi






clear
if test -e /Volumes/OS\ X\ Base\ System*/
then
        echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo          found Volume OS X Base System
	echo
	echo    Remove it, or rename it. And start this tool again
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
exit
else
        echo ++
fi







clear
if test -e /Volumes/Bootstick/
then
        echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo          found Volume Bootstick
	echo
	echo    Remove it, or rename it. And start this tool again
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
exit
else
        echo +++
fi















clear
if test -e /Volumes/Bootstick\ */
then
        echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo          found Volume Bootstick
	echo
	echo    Remove it, or rename it. And start this tool again
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
exit
else
        echo ++++
fi







clear
if test -e ~/Desktop/Install.dmg
then

        echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo         found Install.dmg on the Desktop
	echo
	echo    Remove it, or rename it. And start this tool again
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++

exit
else
        echo ++++++
fi




clear
if test -e ~/Desktop/Install.cdr
then

        echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo          found Install.cdr on the Desktop
	echo
	echo    Remove it, or rename it. And start this tool again
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++

exit
else
        echo +++++++
fi

























if test -e /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg
then
echo found InstallESD.dmg
else

echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

echo /Applications/Install OS X Mavericks.app/Contents/SharedSupport/InstallESD.dmg
echo NOT FOUND

echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

exit

fi


















































clear





hdiutil attach /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app

 

clear



echo ===================================
echo Creating Install.dmg on the Desktop
echo ===================================

hdiutil create -o ~/Desktop/Install -size 6300m -layout SPUD -fs HFS+J  
hdiutil attach ~/Desktop/Install.dmg -noverify -nobrowse -mountpoint /Volumes/install_dmg

clear


echo ============================
echo Restore Image to Install.dmg
echo ============================

asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_dmg -noprompt -noverify -erase


clear


echo ============================
Echo Copying the Folder: Packages
echo ============================
echo ============================
Echo  This takes ABOUT 4 MINUTES
echo ============================




rm /Volumes/OS\ X\ Base\ System*/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System*/System/Installation/
cp -rp /Volumes/install_app/BaseSystem.* /Volumes/OS\ X\ Base\ System*/

clear 



hdiutil detach /Volumes/install_app
hdiutil detach /Volumes/OS\ X\ Base\ System/

  
mv ~/Desktop/Install.dmg  ~/Desktop/Install.cdr
 
clear 



echo ==========
Echo - DONE -
echo ==========


# by ralf.











